#include "e2d/yml/impl/FinalSerializer.h"


void e2d::FinalSerializer::EncodeEntity(YAML::Node& node, const e2d::Entity& entity)
{
	m_ImplSerializer.EncodeComponents(node, &entity);

	if (entity.HasComponent<e2d::Prefeb>())
	{
		ztclog::info("Has prefeb and not encode the data");
	}
	else
	{

#ifdef E2D_BUILD_TRANS
		m_TransSerializer.EncodeComponents(node, &entity);
#endif
#ifdef E2D_BUILD_RENDER
		m_RenderSerializer.EncodeComponents(node, &entity);
#endif
#ifdef E2D_BUILD_AUDIO
		m_AudioSerializer.EncodeComponents(node, &entity);
#endif
#ifdef E2D_BUILD_PHYSICS
		m_PhysicsSerializer.EncodeComponents(node, &entity);
#endif
#ifdef E2D_BUILD_FUI
		m_FuiSerializer.EncodeComponents(node, &entity);
#endif
	}
}

void e2d::FinalSerializer::DecodeEntity(const YAML::Node& node, e2d::Entity& entity)
{
	m_ImplSerializer.DecodeComponents(node, &entity);

	if (entity.HasComponent<e2d::Prefeb>())
	{
		ztclog::info("is prefeb and prevent load more components");
	}
	else
	{
#ifdef E2D_BUILD_TRANS
		m_TransSerializer.DecodeComponents(node, &entity);
#endif
#ifdef E2D_BUILD_RENDER
		m_RenderSerializer.DecodeComponents(node, &entity);
#endif
#ifdef E2D_BUILD_AUDIO
		m_AudioSerializer.DecodeComponents(node, &entity);
#endif
#ifdef E2D_BUILD_PHYSICS
		m_PhysicsSerializer.DecodeComponents(node, &entity);
#endif
#ifdef E2D_BUILD_FUI
		m_FuiSerializer.DecodeComponents(node, &entity);
#endif
	}
}
